def factor(n):
    if n != 0:
        temp = 1
        for i in range(1, n + 1):
            temp = temp * i
        return temp
    else:
        return 1


def step(n):
    if n == 0:
        return 1
    else:
        return n * step(n - 1)


def fab(n):
    # 结束条件
    if n == 1 or n == 2:
        return 1
    else:
        return fab(n - 1) + fab(n - 2)


if __name__ == '__main__':
    print(factor(5))
    print(factor(0))

    # 5 * step(4)
    # 5 * 4 * step(3)
    # 5 * 4 * 3 * step(2)
    # 5 * 4 * 3 * 2* step(1)
    # 5 * 4 * 3 * 2 * 1 * step(0)
    # 5 * 4 * 3 * 2 * 1 * 1
    # 写法简单，执行的速度慢
    print(step(5))

    print(fab(40))
